/**
 * intro: 页面状态的统一管理和保存
 * state:
 *   url: 链接的URL地址
 *   status: 链接的状态
 */
var store = {
  debug: true,
  state: {
    // 初始值为默认地址和默认端口
    inputport: "9090",
    inputurl: "192.168.0.0",
    url: "",
    status: "None",
    mode: "",
    // Camera
    cameraStatus: false,
    Img: ""
  },
  position: {},
  setImg(newValue){
    this.Img = newValue;
  },
  getImg(){
    return this.Img;
  },
  setCameraStatus(newValue){
    console.log(typeof newValue);
    this.cameraStatus = newValue;
  },
  getCameraStatus(){
    return this.cameraStatus;
  },
  setUrlAction(newValue) {
    // if (this.debug) console.log("setUrlAction triggered with: " + newValue);
    this.state.url = newValue;
  },
  getUrlAction() {
    // if (!this.state.url) return "";
    return this.state.url
  },
  setInputportAction(newValue) {
    // if (this.debug) console.log("setInputport triggered with: " + newValue);
    this.inputport = newValue;
  },
  getInputportAction() {
    // if (!this.state.inputport) return "";
    return this.state.inputport
  },
  setInputurlAction(newValue) {
    // if (this.debug) console.log("setInputurl triggered with: " + newValue);
    console.log("setInputurlAction:"+newValue);
    this.inputurl = newValue;
  },
  getInputurlAction() {
    // if (!this.state.inputurl) return "";
    return this.state.inputurl
  },
  setStatusAction(newValue) {
    // if (this.debug) console.log("setStatusAction triggered with: " + newValue);
    this.state.status = newValue;
  },
  getStatusAction() {
    if (!this.state.status) return "";
    return this.state.status
  },
  setModeAction(newValue) {
    // if (this.debug) console.log("setModeAction triggered with: " + newValue);
    this.state.mode = newValue;
  },
  getModeAction() {
    if (!this.state.mode) return "";
    return this.state.mode;
  },
  clearStoreAction() {
    // if (this.debug) console.log("clearStoreAction triggered");
    this.state.url = "";
    this.state.status = "";
  }
};

export { store };
